package mock

import (
	"github.com/pkg/errors"
	"gopkg.in/yaml.v2"
	"io/ioutil"
)

//ReadConfig 获取配置数据
func ReadConfig(filePath string) (mock *Config, err error) {
	var (
		content []byte
	)
	// 读取文件
	if content, err = ioutil.ReadFile(filePath); err != nil {
		err = errors.Wrap(err, "解析config.yaml读取错误")
		return
	}
	// 解析文件
	if yaml.Unmarshal(content, &mock) != nil {
		err = errors.Wrap(err, "解析config.yaml出错")
		return
	}
	return
}
